/*
 *  Class name: LabelTextHandler.java
 *  Version: 1.0
 *  Date: 26.2.2014
 */
package cz.muni.fi.pa165.soccergamesarchive.utils;

import cz.muni.fi.pa165.soccergamesarchive.managedbeans.application.ActionState;
import java.util.Locale;
import java.util.ResourceBundle;

import static javax.faces.context.FacesContext.getCurrentInstance;

/**
 * TODO: Change class name :)
 *
 * @author Michal Ďuriš
 */
public class LabelTextHandler {

    private LabelTextHandler() {
    }

    public static String getFullActionDescriptionText(ActionState state,
                                                      String moduleName)
            throws IllegalStateException {
        ResourceBundle bundle = getCurrentInstance()
                .getApplication().getResourceBundle(
                        getCurrentInstance(), "bundle");

        switch (state) {
            case ADD:
                return bundle.getString(
                        moduleName.toLowerCase(Locale.ENGLISH) + "AddTitle");
            case EDIT:
                return bundle.getString(
                        moduleName.toLowerCase(Locale.ENGLISH) + "ChangeTitle");
            default:
                throw new IllegalStateException();
        }
    }

    public static String getActionDescriptionText(ActionState state) throws
            IllegalStateException {
        ResourceBundle bundle = getCurrentInstance()
                .getApplication().getResourceBundle(
                        getCurrentInstance(), "bundle");

        switch (state) {
            case ADD:
                return bundle.getString("addButton");
            case EDIT:
                return bundle.getString("editButton");
            default:
                throw new IllegalStateException();
        }
    }

}
